package com.situ.javase.day3;

import java.util.Scanner;

import javax.swing.text.AbstractDocument.BranchElement;

import org.junit.Test;

public class SwitchDemo {

	@Test
	public void test1() {
		int type = 3;
		switch (type) {
		case 1:
			System.out.println("1");
			break;
		case 2:
			System.out.println("2");
			break;
		case 3:
			System.out.println("3");
			break;
		default:
			System.out.println("default");
			break;
		}
	}

//	输入月份、年份判断天数：
//	1、3、5、7、8、10、12  -------- 31天
//	4、6 、9、11--------------------30天
//	2----------------------------------28/29天
	@Test
	public void test2() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入月份：");
		int month = scanner.nextInt();
		// case只有遇到break才推出，否则从上往下执行
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			System.out.println("31天");
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			System.out.println("30天");
			break;
		case 2:
			// 让用户输入年份，根据是不是闰年判断有多少天
			break;
		default:
			System.out.println("defalut");
			break;
		}
	}
	
//  >=90   <=100   优秀
//  >=80    <90       良好
//  >=70    <80       一般
//  >=60    <70      及格
//  <60                    不及格
	@Test
	public void test5() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入学生成绩：");
		int score = scanner.nextInt();
		if (score < 0 || score > 100) {
			System.out.println("成绩非法");
			return;
		}
		
		switch (score / 10) {
		case 9:
		case 10:
			System.out.println("优秀");
			break;
		case 8:
			System.out.println("良好");
			break;
		case 7:
			System.out.println("一般");
			break;
		case 6:
			System.out.println("及格");
			break;
		default:
			System.out.println("不及格");
			break;
		}
	}
	
	@Test
	public void test44() {
		String type = "/";
		switch (type) {
		case "+":
			System.out.println("+");
			break;
		case "-":
			System.out.println("-");
			break;
		case "*":
			System.out.println("*");
			break;
		case "/":
			System.out.println("/");
			break;
		default:
			break;
		}
		
	}

}
